package top.drinyeit.nongmao.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import top.drinyeit.nongmao.R;

/**
 * Created by Administrator on 2017/12/8.
 */

public class AllOrderAdapter extends BaseAdapter {

    private Context context;
    private LayoutInflater mInflater;

    public AllOrderAdapter(Context context) {
        this.context = context;
        mInflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return 40;
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        //订单分4块
        ViewHolder0 viewHolder0;
        if (convertView == null) {
            viewHolder0 = new ViewHolder0();
            switch (position % 4) {
                case 0:
                    convertView = mInflater.inflate(R.layout.item_order_title, null);
                    viewHolder0.shop_name = convertView.findViewById(R.id.shop_name);
                    viewHolder0.order_state = convertView.findViewById(R.id.order_state);
                    convertView.setTag(viewHolder0);
                    break;
                case 1:
                    convertView = mInflater.inflate(R.layout.item_order_merchandise, null);
                    viewHolder0.img = convertView.findViewById(R.id.img);
                    viewHolder0.merchandise_name = convertView.findViewById(R.id.merchandise_name);
                    viewHolder0.discount_price = convertView.findViewById(R.id.discount_price);
                    viewHolder0.price = convertView.findViewById(R.id.price);
                    viewHolder0.number = convertView.findViewById(R.id.number);
                    convertView.setTag(viewHolder0);
                    break;
                case 2:
                    convertView = mInflater.inflate(R.layout.item_order_total, null);
                    viewHolder0.number = convertView.findViewById(R.id.number);
                    viewHolder0.money = convertView.findViewById(R.id.money);
//                    viewHolder0.send_fee = convertView.findViewById(R.id.send_fee);
                    convertView.setTag(viewHolder0);
                    break;
                default:
                    convertView = mInflater.inflate(R.layout.item_order_btn, null);
                    viewHolder0.overOrder = convertView.findViewById(R.id.overOrder);
                    convertView.setTag(viewHolder0);
                    break;
            }
        } else {
            switch (position % 4) {
                case 0:
                    viewHolder0 = (ViewHolder0) convertView.getTag();
//                    viewHolder0.shop_name.setText("");
                    break;
                case 1:
                    viewHolder0 = (ViewHolder0) convertView.getTag();
//                    viewHolder0.price.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);
                    break;
                case 2:
                    viewHolder0 = (ViewHolder0) convertView.getTag();
//                    viewHolder0.send_fee.setText(")");
                    break;
                default:
                    viewHolder0 = (ViewHolder0) convertView.getTag();
//                    viewHolder0.overOrder.setVisibility(View.VISIBLE);
                    break;
            }

        }

//        switch (position % 4){
//            case 0:
//                viewHolder0.shop_name.setText("");
//                break;
//            case 1:
////                viewHolder0.price.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);
//                break;
//            case 2:
//                viewHolder0.send_fee.setText(")");
//                break;
//            default:
//                viewHolder0.overOrder.setVisibility(View.VISIBLE);
//                break;
//        }

        return convertView;
    }


    private class ViewHolder0 {
        TextView shop_name;
        TextView order_state;

        ImageView img;
        TextView merchandise_name;
        TextView discount_price;
        TextView price;

        TextView number;
        TextView money;
        TextView send_fee;

        RelativeLayout overOrder;
    }

    private class ViewHolder1 {

    }

    private class ViewHolder2 {

    }

    private class ViewHolder3 {

    }
}
